﻿#region Header

/*
Remote views based on linq
By

Pascal Hauser 
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

and

Raphael Gfeller
Dipl. Ing. in Informatik, Hochschule für Technik Rapperswil, 2006
Master Thesis, Hochschule für Technik Rapperswil, 2008-2010

*/

#endregion

#region Usings

using Microsoft.VisualStudio.TestTools.UnitTesting;
using Sebarf.Diagnostics.Interfaces;

#endregion

namespace Diagnositcs.Test {
	/// <summary>
	/// Tests the <see cref="Logger"/>
	/// </summary>
	[TestClass]
	public class TestLogger {
		#region Test Methods

		[TestMethod]
		public void TestLoggerInit() {
			Logger.ResetLoggerInstance();
			Assert.IsTrue(Logger.LoggerImpl is SimpleLoggerService);
		}

		[TestMethod]
		public void TestWriteError() {
			// logger instance
			var logger = new DummyLogger();

			// init logger
			Logger.LoggerImpl = logger;

			// log error
			Logger.WriteError("Error");

			// check if log entry is written
			Assert.AreEqual(1, logger.LogEntries.Count);
			Assert.AreEqual(logger.LogEntries[0], "Error");
		}

		[TestMethod]
		public void TestWriteWarning() {
			// logger instance
			var logger = new DummyLogger();

			// init logger
			Logger.LoggerImpl = logger;

			// log error
			Logger.WriteWarning("Warning");

			// check if log entry is written
			Assert.AreEqual(1, logger.LogEntries.Count);
			Assert.AreEqual(logger.LogEntries[0], "Warning");
		}

		[TestMethod]
		public void TestWriteDebug() {
			// logger instance
			var logger = new DummyLogger();

			// init logger
			Logger.LoggerImpl = logger;

			// log error
			Logger.WriteDebug("Debug");

			// check if log entry is written
			Assert.AreEqual(1, logger.LogEntries.Count);
			Assert.AreEqual(logger.LogEntries[0], "Debug");
		}

		#endregion
	}
}